<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="__PUBLIC__/dataapi/css/themes/bootstrap/easyui.css">
    <link rel="stylesheet" href="__PUBLIC__/dataapi/css/themes/color.css">
    <link rel="stylesheet" href="__PUBLIC__/dataapi/css/themes/icon.css">
    <link rel="stylesheet" href="__PUBLIC__/dataapi/css/themes/mobile.css">
    <script src="__PUBLIC__/dataapi/js/jquery.min.js"></script>
    <script src="__PUBLIC__/dataapi/js/jquery.easyui.min.js"></script>
    <script src="__PUBLIC__/dataapi/js/easyloader.js"></script>
</head>
<body class="easyui-layout">
<div data-options="region:'center',title:'Excel上传商品列表'" style="padding:0px;background:#eee;">
    <table id="dg"></table>
</div>
<script>
    data = <?php echo $goods?>;
    function pagerFilter(data){
        if (typeof data.length == 'number' && typeof data.splice == 'function'){	// is array
            data = {
                total: data.length,
                rows: data
            }
        }
        var dg = $(this);
        var opts = dg.datagrid('options');
        var pager = dg.datagrid('getPager');
        pager.pagination({
            onSelectPage:function(pageNum, pageSize){
                opts.pageNumber = pageNum;
                opts.pageSize = pageSize;
                pager.pagination('refresh',{
                    pageNumber:pageNum,
                    pageSize:pageSize
                });
                dg.datagrid('loadData',data);
            }
        });
        if (!data.originalRows){
            data.originalRows = (data.rows);
        }
        var start = (opts.pageNumber-1)*parseInt(opts.pageSize);
        var end = start + parseInt(opts.pageSize);
        data.rows = (data.originalRows.slice(start, end));
        return data;
    }

    $(function(){
        var products = 0;
        $('#dg').datagrid({
            columns:[[
                {field:'earn13',title:'商品编码',width:100,align:'center'},
                {field:'name',title:'商品名称',resizable:true,width:120,align:'center'},
                {field:'info_keywords',title:'商品关键字',width:100,align:'center'},
                {field:'weight',title:'重量',width:40,align:'center'},
                {field:'pom',title:'计量单位',width:40,align:'center'},
                {field:'info_pc',title:'PC端图片',width:100,align:'center'},
                {field:'info_mobile',title:'手机端图片',width:100,align:'center'},
                {field:'market_price',title:'市场价',width:40,align:'center'},
                {field:'acting_price',title:'一键代发价',width:48,align:'center'},
                {field:'wholesale_price',title:'批发价',width:40,align:'center'},
                {field:'lock_price',title:'锁库价',width:40,align:'center'},
                {field:'wholesale_start_num',title:'最低批发数量',width:60,align:'center'},
                {field:'lock_start_num',title:'最低锁库数量',width:60,align:'center'},
                {field:'price',title:'商品原价',width:40,align:'center'},
                {field:'stock_num',
                    title:'库存',
                    width:40,
                    align:'center',
                    editor:{
                        type:'combobox',
                        options:{
                            valueField:'productid',
                            textField:'name',
                            data:products,
                            required:true
                        }
                }},
                {field:'createdtime',title:'导入时间',width:100,align:'center'},
                {field:'is_sync',title:'是否同步',width:40,align:'center'},
                {field:'batch',title:'导入批次',width:100,align:'center'}
            ]],
            rownumbers:true,
            fitColumns:true,
            striped:true,
            nowrap:true,
            pagination:true,
            pagePosition:'bottom',
            pageNumber:1,
            pageSize:10,
            showFooter:true,
            data :data,
            total : 100,
            toolbar:[
                {
                    iconCls: 'icon-edit',
                    handler: function(){alert('编辑按钮')}
                },
                {
                    iconCls: 'icon-help',
                    handler: function(){alert('帮助按钮')}
                }
            ]
        });
        $('#dg').datagrid({loadFilter:pagerFilter});
    });
</script>
</body>
</html>